 package util;
 
 import java.util.Vector;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.config.RequestConfig.Builder;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.ByteArrayEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.client.LaxRedirectStrategy;
 import org.apache.http.util.EntityUtils;
 
 public class HttpUtil
 {
   public static final int CON_TIMEOUT = 15000;
   public static final int READ_TIMEOUT = 45000;
   
   public static final byte[] httpGet(String url, Vector<String[]> header)
   {
     CloseableHttpClient client = HttpClients.createDefault();
     RequestConfig config = RequestConfig.custom().setConnectTimeout(15000).setSocketTimeout(45000).build();
     HttpGet hg = new HttpGet(url);
     hg.setConfig(config);
     
     if (header != null) {
       for (String[] strs : header) {
         hg.setHeader(strs[0], strs[1]);
       }
     }
     try {
       HttpResponse resp = client.execute(hg);
       HttpEntity entity = resp.getEntity();
       return EntityUtils.toByteArray(entity);
 
     }
     catch (Exception e)
     {
       e.printStackTrace(); }
     return null;
   }
   
   public static final byte[] httpPost(String url, byte[] postData, Vector<String[]> header)
   {
     LaxRedirectStrategy redirectStrategy = new LaxRedirectStrategy();
     CloseableHttpClient client = HttpClients.custom().setRedirectStrategy(redirectStrategy).build();
     RequestConfig config = RequestConfig.custom().setConnectTimeout(15000).setSocketTimeout(45000).build();
     HttpPost hp = new HttpPost(url);
     hp.setConfig(config);
     
     if (postData != null) {
       HttpEntity pEntity = new ByteArrayEntity(postData);
       hp.setEntity(pEntity);
     }
     
     if (header != null) {
       for (String[] strs : header) {
         hp.setHeader(strs[0], strs[1]);
       }
     }
     try {
       HttpResponse resp = client.execute(hp);
       HttpEntity entity = resp.getEntity();
       return EntityUtils.toByteArray(entity);
 
     }
     catch (Exception e)
     {
       e.printStackTrace();
     }
     return null;
   }
 }


/* Location:              /home/cp/server/java/AndroidSdkServer.jar!/com/eyumob/common/util/HttpUtil.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */